using Microsoft.EntityFrameworkCore;
using STF.Blog.IRepository;
using STF.Blog.IService;
using STF.Blog.Model;
using STF.Blog.Repository;
using STF.Blog.Service;

var builder = WebApplication.CreateBuilder(args);

var conf = builder.Configuration.GetConnectionString("ForumKey");

builder.Services.AddControllersWithViews();

builder.Services.AddDbContext<BlogContext>(options => options.UseSqlServer(conf));

builder.Services.AddScoped<IRolesManager, RolesManager>();
builder.Services.AddScoped<IRolesService, RolesService>();

builder.Services.AddScoped<IAdminsManager, AdminsManager>();
builder.Services.AddScoped<IAdminsService, AdminsService>();

builder.Services.AddScoped<IFriendLinkManager, FriendLinkManager>();
builder.Services.AddScoped<IFriendLinkService, FriendLinkService>();

builder.Services.AddScoped<ICopyrightManager, CopyrightManager>();
builder.Services.AddScoped<ICopyrightService, CopyrightService>();

builder.Services.AddScoped<IFansManager, FansManager>();
builder.Services.AddScoped<IFansService, FansService>();

builder.Services.AddScoped<IUsersManager, UsersManager>();
builder.Services.AddScoped<IUsersService, UsersService>();

builder.Services.AddScoped<IAdminPermissionsManager, AdminPermissionsManager>();
builder.Services.AddScoped<IAdminPermissionsService, AdminPermissionsService>();

builder.Services.AddScoped<ISystemMenusManager, SystemMenusManager>();
builder.Services.AddScoped<ISystemMenusService, SystemMenusService>();

builder.Services.AddScoped<IUsersInfoManager, UsersInfoManager>();
builder.Services.AddScoped<IUsersInfoService, UsersInfoService>();

builder.Services.AddScoped<IWebMenuManager, WebMenuManager>();
builder.Services.AddScoped<IWebMenuService, WebMenuService>();

builder.Services.AddScoped<ISeosManager, SeosManager>();
builder.Services.AddScoped<ISeosService, SeosService>();

builder.Services.AddScoped<ILevelManager, LevelManager>();
builder.Services.AddScoped<ILevelService, LevelService>();

builder.Services.AddScoped<IReleaseFormManager, ReleaseFormManager>();
builder.Services.AddScoped<IReleaseFormService, ReleaseFormService>();

builder.Services.AddScoped<IArticleCateGoryManager, ArticleCateGoryManager>();
builder.Services.AddScoped<IArticleCateGoryService, ArticleCateGoryService>();

builder.Services.AddScoped<IClassifyColumnManager, ClassifyColumnManager>();
builder.Services.AddScoped<IClassifyColumnService, ClassifyColumnService>();

builder.Services.AddScoped<ICategoryManager, CategoryManager>();
builder.Services.AddScoped<ICategoryService, CateGoryService>();

builder.Services.AddScoped<IBlogManager, BlogManager>();
builder.Services.AddScoped<IBlogService, BlogService>();

builder.Services.AddScoped<ICommentManager, CommentManager>();
builder.Services.AddScoped<ICommentService, CommentService>();

builder.Services.AddScoped<IReplyManager, ReplyManager>();
builder.Services.AddScoped<IReplyService, ReplyService>();

builder.Services.AddScoped<ICoverManager, CoverManager>();
builder.Services.AddScoped<ICoverService, CoverService>();

builder.Services.AddScoped<IArticleCategoryOwnershipManager, ArticleCategoryOwnershipManager>();
builder.Services.AddScoped<IArticleCategoryOwnershipService, ArticleCategoryOwnershipService>();

builder.Services.AddScoped<IBlogCateGoryManager, BlogCateGoryManager>();
builder.Services.AddScoped<IBlogCateGoryService, BlogCateGoryService>();

builder.Services.AddSession();

var app = builder.Build();

app.UseStaticFiles();
app.UseRouting();
app.UseSession();

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllerRoute(
      name: "areas",
      pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
    );
});

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllerRoute(
      name: "stateCode",
      pattern: "{area:exists}/{controller=Home}/{action=Index}/{page?}/{stateCode?}"
    );
});

app.UseEndpoints(endpoints => endpoints.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}"
    )
);

app.UseEndpoints(endpoints => endpoints.MapControllerRoute(
    name: "CateGory",
    pattern: "{controller=Home}/{action=Index}/{id?}/{typeId?}"
    )
);


app.Run();
